package com.wct.mall.controller;

import com.wct.mall.common.JsonData;
import com.wct.mall.domain.PmsBrand;
import com.wct.mall.service.PmsBrandService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * content-type ：application/json
 * @author WEI
 * @date 2020/3/22
 */
@Controller
@RequestMapping("/api/brand")
@Slf4j
public class PmsBrandController {

    @Autowired
    private PmsBrandService pmsBrandService;

    @GetMapping("/save.json")
    @ResponseBody
    public JsonData save(PmsBrand param) {
        log.debug("save ：{}", param);
        pmsBrandService.insert(param);
        return JsonData.success(null, "保存成功");
    }

    @PostMapping("/update.json")
    @ResponseBody
    public JsonData update(PmsBrand param){
        pmsBrandService.update(param);
        return JsonData.success(null, "更新成功");

    }

    @PostMapping("/delete.json")
    @ResponseBody
    public JsonData delete( int id) {
        log.debug("delete id: {}", id);
        pmsBrandService.delete(id);
        return JsonData.success(null, "删除成功");
    }

    @GetMapping("/get.json")
    @ResponseBody
    public JsonData get(int id) {
        log.debug("get1 id: {}", id);
        return JsonData.success(pmsBrandService.get(id));
    }

    @GetMapping("/get2.json")
    @ResponseBody
    public JsonData get2(int id) {
        log.debug("get2 id: {}", id);
        return JsonData.success(pmsBrandService.get(id));
    }

    @GetMapping("/list.json")
    @ResponseBody
    public JsonData list() {
        return JsonData.success(pmsBrandService.list());
    }
}
